// pages/myKeep/detail.js
const app = getApp();
var utils = require('../../utils/util.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    
    var sucFunc = function (that, res) {
      console.log(res.data)
      var youAnswer = '';
      res.data.xa = res.data.answer.indexOf(res.data.optiona) != -1 ? 2 : 1;
      res.data.xb = res.data.answer.indexOf(res.data.optionb) != -1 ? 2 : 1;
      res.data.xc = res.data.answer.indexOf(res.data.optionc) != -1 ? 2 : 1;
      res.data.xd = res.data.answer.indexOf(res.data.optiond) != -1 ? 2 : 1;
      youAnswer   = res.data.answer.indexOf(res.data.optiona) != -1 ? youAnswer + 'A' : youAnswer;
      youAnswer   = res.data.answer.indexOf(res.data.optionb) != -1 ? youAnswer + 'B' : youAnswer;
      youAnswer   = res.data.answer.indexOf(res.data.optionc) != -1 ? youAnswer + 'C' : youAnswer;
      youAnswer   = res.data.answer.indexOf(res.data.optiond) != -1 ? youAnswer + 'D' : youAnswer
      res.data.youAnswer = youAnswer
      that.setData({
        item: res.data
      })
    }
    var data = { id: options.id }
    utils.wxRequest(that, app.d.path, "Profession/myKeepDetail", data, sucFunc);
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})